const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
// 定义路由中间件
const router = express.Router();
const app = express();

app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
// 静态资源
app.use('/static', express.static(path.join(__dirname, 'public')));

router.get('/home', (req,res) => {
  res.send('我是home页')
})
router.post('/login', (req,res) => {
  res.send('登录成功')
})
// 使用路由中间件
app.use(router);
app.listen(3000, () => {
  console.log('start at port 3000');
})